var mongoose=require('mongoose');
mongoose.connect('mongodb://localhost/DBRef');

var User=mongoose.model('User',{
    name:String
});

var News=mongoose.model('News',{
    title:String,
    author:{
        type:mongoose.Schema.ObjectId,
        ref:'User'
    },
    comments:[{
        content:String,
        like:{
            type:Number,
            default:0
        }
    }]
});

//test
var title='News e';

News.update({title:title},{$push:{
    comments:{
        $each:[{content:'c d 1'},{content:'c d 2'},{content:'c d 3'}]
    }
}},(err,r)=>{
    console.log(err,r);
})